/**
 * All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
 *
 * @version 版本：1.0
 * @author 作者：lanjianwei 创建日期：2021-01-07
 */

package com.topscomm.gpm.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.topscomm.basic.exception.MessageException;
import com.topscomm.gpm.controller.auto.GpmProjectTaskControllerAuto;
import com.topscomm.gpm.pojo.*;
import com.topscomm.gpm.pojo.GpmProjectMilepostEntity;
import com.topscomm.gpm.service.impl.*;
import com.topscomm.pub.util.BaseUtil;
import com.topscomm.pub.vo.Page;
import com.topscomm.pub.vo.Query;
import com.topscomm.tap.common.TapSystemConst.TapApprovalBillStateEnum;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.topscomm.basic.util.SQLAdapter;
import com.topscomm.cbo.service.impl.CboItemDetailsService;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.util.DateUtil;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import com.topscomm.pub.vo.ResponseResult;

/**
 * @author: lanjianwei
 * @date: 2021-01-07
 * @description:项目任务Controller
 * @modify:
 */
@RestController
@RequestMapping("sd/projectTask")
public class GpmProjectTaskController extends GpmProjectTaskControllerAuto implements
        IGpmProjectTaskController {

    @Autowired
    private GpmProjectTaskFeedbackService gpmProjectTaskFeedbackService;
    @Autowired
    private GpmProjectMilepostService gpmProjectMilepostService;
    @Autowired
    private GpmProjectTaskCloseService gpmProjectTaskCloseService;
    @Resource(name = "gpmProjectTaskService")
    private GpmProjectTaskService gpmProjectTaskService;
    @Autowired
    private GpmProjectService gpmProjectService;
    @Autowired
    private CboItemDetailsService cboItemDetailsService;

    /**
     * @author: lanjianwei
     * @date: 2021-01-07
     * @param paraMap
     * @return
     * @description:转换出查询SQL语句
     * @modify:
     */
    @Override
    protected String spellListSql(Map<String, Object> paraMap) {
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" enabled=1 ");
        if (paraMap.containsKey("qry_responsible")) {
            String value = paraMap.get("qry_responsible").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and (responsiblecode = '{0}' or responsible like '%{0}%') ",
                        value);
            }
        }
        if (paraMap.containsKey("qry_user")) {
            String value = paraMap.get("qry_user").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and (applyusercode = '{0}' or applyusername like '%{0}%') ",
                        value);
            }
        }
        // 任务状态查询条件
        if (paraMap.containsKey("qry_taskstate")) {
            String value = paraMap.get("qry_taskstate").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and taskstate in  ({0})", value);
            }
        }
        if (paraMap.containsKey("qry_responsiblecode")) {
            String value = paraMap.get("qry_responsiblecode").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and responsiblecode = '{0}'", value);
            }
        }
        if (paraMap.containsKey("qry_projectname")) {
            String value = paraMap.get("qry_projectname").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and projectname like '%{0}%'", value);
            }
        }
        if (paraMap.containsKey("qry_projectcode")) {
            String value = paraMap.get("qry_projectcode").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and projectcode = '{0}'", value);
            }
        }
        if (paraMap.containsKey("qry_milepostcode")) {
            String value = paraMap.get("qry_milepostcode").toString();
            if (!StringUtil.isEmpty(value)) {
            	if(paraMap.containsKey("qry_milepostid") && !StringUtil.isEmpty(paraMap.get("qry_milepostid").toString())) {
            		sql.appendSingle(" and (milepostcode = '{0}' and milepostversion <= (select version from GPMprojectmilepost where id='{1}'))",
                    		value,paraMap.get("qry_milepostid").toString());
            	} else {
            		sql.appendSingle(" and (milepostcode = '{0}')",value);
            	}
            }
        }
        if (paraMap.containsKey("qry_milepostname")) {
            String value = paraMap.get("qry_milepostname").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and milepostname like '%{0}%'", value);
            }
        }
        if (paraMap.containsKey("qry_taskname")) {
            String value = paraMap.get("qry_taskname").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and taskname like '%{0}%'", value);
            }
        }
        if (paraMap.containsKey("qry_state")) {
            String value = paraMap.get("qry_state").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and state={0}", value);
            }
        }
        if (paraMap.containsKey("qry_docno")) {
            String value = paraMap.get("qry_docno").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and docno like '%{0}%'", value);
            }
        }
        if (paraMap.containsKey("qry_begindocdate")) {
            String value = paraMap.get("qry_begindocdate").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and docdate >= {0} ",
                        SQLAdapter.toDateLong(value + " 00:00:00"));
            }
        }
        if (paraMap.containsKey("qry_enddocdate")) {
            String value = paraMap.get("qry_enddocdate").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and docdate <= {0}", SQLAdapter.toDateLong(value + " 23:59:59"));
            }
        }
        if (paraMap.containsKey("qry_deptname")) {
            String value = paraMap.get("qry_deptname").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(
                        " and (deptid in ( SELECT id from CboDept where fullname like '%{0}%'))",
                        value);
            }
        }
        if (paraMap.containsKey("qry_username")) {
            String value = paraMap.get("qry_username").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and (username like '%{0}%')", value);
            }
        }
        if (paraMap.containsKey("qry_deptcode")) {
            String value = paraMap.get("qry_deptcode").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and deptcode like '{0}%'", value);
            }
        }
        if (paraMap.containsKey("qry_where")) {
            String value = paraMap.get("qry_where").toString();
            if (!StringUtil.isEmpty(value)) {
                sql.appendSingle(" and {0}", value);
            }
        }
        if (paraMap.containsKey("isoverdate")) {
            String isoverdate = (String) paraMap.get("isoverdate");
            //超期任务页面
            if ("1".equals(isoverdate)) {
                String timeNow = DateUtil.dateToString(new Date(), "yyyy-MM-dd");
                sql.appendSingle(" and planenddate < {0}", SQLAdapter.toDateShort(timeNow));
            }
        }
        if (paraMap.containsKey("qry_permission")) {
            String value = paraMap.get("qry_permission").toString();
            sql.appendSingle("and " + gpmProjectService
                    .whereExistsSqlForIndex(GpmProjectTaskEntity.tableName, GpmProjectTaskEntity.FieldProjectid, value));
        }
        if (paraMap.containsKey("qry_forIndexQuery")) {
        	if(paraMap.containsKey("qry_projectcode")) {
        		sql.appendSingle(" AND MILEPOSTCODE IN (SELECT OPERATECODE FROM GPMPROJECTMILEPOST WHERE (ENABLED  = '1')and projectcode = '{0}')"
        				,paraMap.get("qry_projectcode").toString());
        	} else {
        		sql.appendSingle(" AND MILEPOSTCODE IN (SELECT OPERATECODE FROM GPMPROJECTMILEPOST WHERE ENABLED  = '1')");
        	}
        }
        return sql.toString();
    }


    @Override
    @PutMapping({"/submit"})
    public ResponseResult<Object> submit(
            @RequestBody(required = false) Map<String, Object> paraMap) {
        // 下发任务和批量下发都需要调用此接口，当下发任务时，paramap中的value值为JSONObject类型，进行转换
        String string = paraMap.get("modelArray").getClass().toString();
        String substring = string.substring(string.lastIndexOf(".") + 1);
        if (substring.equals("JSONObject")) {
            JSONArray array = new JSONArray();
            array.add(paraMap.get("modelArray"));
            paraMap.put("modelArray", array);
        }
        JSONArray modelArray = (JSONArray) paraMap.get("modelArray");
        List<Map<String, Object>> list = new ArrayList<>();
        if (modelArray != null) {
            for (int j = 0; j < modelArray.size(); j++) {
                JSONObject jsonObject = modelArray.getJSONObject(j);
                Map<String, Object> map = JSONObject.toJavaObject(jsonObject, Map.class);
                list.add(map);
            }
            for (Map<String, Object> result : list) {
                try {
                    Map<String, Object> dataMap = result;
                    result.put("submitdate", new Date());
                    this.beforeSubmit(result, result);
                    String mailTitle = "";
                    if (result.containsKey("maintitle")) {
                        mailTitle = ConvertUtil.convertToString(result.get("maintitle"));
                    }
                    GpmProjectTaskEntity taskEntity = this.service
                            .queryById(ConvertUtil.convertToString(result.get("id")));
                    if (TapApprovalBillStateEnum.Approveing != ConvertUtil
                            .convertToInt(taskEntity.getValue("state"))
                            && TapApprovalBillStateEnum.Approved != ConvertUtil
                            .convertToInt(taskEntity.getValue("state"))) {
                        Iterator<String> var6 = result.keySet().iterator();
                        while (var6.hasNext()) {
                            Object key = var6.next();
                            String tempkey = ConvertUtil.convertToString(key);
                            taskEntity.setValue(tempkey, dataMap.get(key));
                        }
                        this.service.executeSubmit(taskEntity, mailTitle, this.getUserBean());
                        dataMap = this.service
                                .queryMapById(ConvertUtil.convertToString(dataMap.get("id")));
                        this.afterSubmit(dataMap, result);
                    }
                } catch (Exception var8) {
                    return this.handleControllerException(var8);
                }
            }
            return ResponseResult.ok("提交成功");
        } else {
            return ResponseResult.error("请选择数据！");
        }
    }


    @Override
    protected void beforeSubmit(Map<String, Object> dataMap, Map<String, Object> paraMap)
            throws Exception {
        StringBufferProxy mailtitle = new StringBufferProxy();
        mailtitle.appendSingle("{0}{1}于{2}提交项目任务申请! ", dataMap.get("dispdeptcode"),
                dataMap.get("username"), DateUtil.dateToString(new Date(), "yyyy-MM-dd"));
        dataMap.put("maintitle", mailtitle.toString());
        SimpleDateFormat simple1 = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        String format = simple1.format(new Date());
        // Date dateNow = simple1.parse(format);
        SimpleDateFormat simple2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String planstartdate =
                ConvertUtil.convertToString(paraMap.get("planstartdate")) + " 00:00:00";
        Date taskPlanStartDate = simple2.parse(planstartdate);
        String planenddate = ConvertUtil.convertToString(paraMap.get("planenddate")) + " 00:00:00";
        Date taskPlanEndDate = simple2.parse(planenddate);
        if (taskPlanStartDate.compareTo(taskPlanEndDate) > 0) {
            throw new MessageException("任务的计划开始日期不能大于计划完成日期！");
        }
//		if(taskPlanStartDate.compareTo(dateNow)<0){
//			throw new MessageException("任务的计划开始日期不能小于今天！");
//		}
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle("operatecode = '{0}'  and  enabled=1 ", paraMap.get("milepostcode"));
        List<GpmProjectMilepostEntity> gpmProjectMilepostEntityList = gpmProjectMilepostService
                .queryByWhere(sql.toString());
        if(gpmProjectMilepostEntityList.size()==0) {
            sql.clear();
            sql.appendSingle("operatecode = '{0}'", paraMap.get("milepostcode"));
            gpmProjectMilepostEntityList = gpmProjectMilepostService.queryByWhere(sql.toString());
        }
        Date planfinishtime = gpmProjectMilepostEntityList.get(0).getPlanfinishtime();
        if(planfinishtime == null) {
            throw new MessageException("请先填写所属里程碑完成时间！");
        }
        if (taskPlanEndDate.compareTo(planfinishtime) > 0) {
            throw new MessageException("任务的计划完成日期不能大于所属里程碑的计划达成日期！");
        }
    }


    @Override
    @GetMapping({"/list"})
    public ResponseResult<Object> list(
            @RequestParam(required = false) Map<String, Object> paraMap) {
        try {
            paraMap = BaseUtil.decodeSecureMap(paraMap);
            Query query = new Query(paraMap);
            String sqlWhere = this.spellListSql(paraMap);
            int totalCount = this.service.getCount(sqlWhere);
            List<Map<String, Object>> tempList = null;
            HashMap<String, Object> paraMap2 = new HashMap<>();
            paraMap2.put("curPageIndex", query.getCurrentPage());
            int beginCount = query.getCurrentPage() * query.getPageSize() - query.getPageSize();
            paraMap2.put("begincount", beginCount);
            paraMap2.put("pagesize", query.getPageSize());
            paraMap2.put("sidx", query.getSidx());
            paraMap2.put("sord", query.getSord());
            paraMap2.put("whereSql", sqlWhere);
            if (query.getPageSize() > 0) {
                tempList = this.service.queryMapForPage(paraMap2, "getMapForPage");
            } else {
                tempList = this.service.queryMap(paraMap2, "getMapByWhere");
            }
            if (CollectionUtils.isEmpty(tempList)) {
                return ResponseResult.ok(new Page(tempList, totalCount, query.getPageSize(), query.getCurrentPage()));
            }
            // 为任务配置编号
            if(query.getPageSize() > 0) {
               List<Map<String,Object>> resList = this.service.queryMap(paraMap2, "getMapByWhere");
               this.service.generateTaskcode(resList);
               tempList.forEach(temp -> {
                   resList.forEach(res -> {
                       if(ConvertUtil.convertToString(temp.get("id")).equals(ConvertUtil.convertToString(res.get("id")))){
                            temp.put("generatetaskcode",res.get("generatetaskcode"));
                       }
                   });
               });
            } else {
                this.service.generateTaskcode(tempList);
            }
            this.service.getProjectInfo(tempList);
            this.service.setDispFields(tempList);
            this.service.getTaskFeedbackInfo(tempList);
            Page page = new Page(tempList, totalCount, query.getPageSize(), query.getCurrentPage());
            return ResponseResult.ok(page);
        } catch (Exception var7) {
            return this.handleControllerException(var7);
        }
    }


    /**
     * @author: lanjianwei
     * @date: 2021-01-07
     * @param paraMap
     * @return
     * @description:转换出查询SQL语句
     * @modify:
     */
    @Override
    @GetMapping(value = "/refList")
    public ResponseResult<Object> refList(
            @RequestParam(required = false) Map<String, Object> paraMap) {
        return super.refList(paraMap);
    }

    /**
     * @Title: insertFromProject
     * @description: 按照项目插入任务
     * @param paraMap
     * @return
     * @author: lanjianwei
     * @date: 2021年1月12日下午5:22:14
     * @modify:
     */
    @PostMapping(value = "/insertFromProject")
    public ResponseResult<Object> insertFromProject(
            @RequestBody(required = false) Map<String, Object> paraMap) {
        try {
            ResponseResult responseResult = gpmProjectTaskService.insertFromProject(paraMap);
            return responseResult;
        } catch (Exception ex) {
            return ResponseResult.error("插入项目任务出错，请联系管理员!");
        }
    }

    /**
     * @Title: insertFromTaskTemplate
     * @description:按照模板插入任务
     * @param paraMap
     * @return
     * @author: lanjianwei
     * @date: 2021年1月14日下午6:19:51
     * @modify:
     */
    @PostMapping(value = "/insertFromTaskTemplate")
    public ResponseResult<Object> insertFromTaskTemplate(
            @RequestBody(required = false) Map<String, Object> paraMap) {
        try {
            ResponseResult responseResult = gpmProjectTaskService.insertFromTaskTemplate(paraMap);
            return responseResult;
        } catch (Exception ex) {
            return ResponseResult.error("插入项目任务出错，请联系管理员!");
        }
    }

    /**
     * @Title: startTask
     * @description:开始任务
     * @param paraMap
     * @return
     * @author: lanjianwei
     * @date: 2021年1月14日下午6:20:52
     * @modify:
     */
    @PostMapping(value = "/start")
    public ResponseResult<Object> startTask(
            @RequestBody(required = false) Map<String, Object> paraMap) {
        try {
            ResponseResult responseResult = gpmProjectTaskService.startTask(paraMap);
            return responseResult;
        } catch (Exception ex) {
            return ResponseResult.error("开始项目任务出错，请联系管理员!");
        }
    }

    /**
     * @Title: startTask
     * @description:首页我的任务数量
     * @param paraMap
     * @return
     * @author: lanjianwei
     * @date: 2021年1月14日下午6:20:52
     * @modify:
     */
    @GetMapping(value = "/myTaskCount")
    public ResponseResult<Object> myTaskCount(
            @RequestParam(required = false) Map<String, Object> paraMap) {
        try {
            int count = gpmProjectTaskService.getCount(spellListSql(paraMap));
            return ResponseResult.ok(count);
        } catch (Exception ex) {
            StackTraceElement[] stackTrace = ex.getStackTrace();
            for (StackTraceElement item : stackTrace) {
            }
            return ResponseResult.error("我的任务查询出错，请联系管理员!");
        }
    }

    @Override
    protected void beforeInsert(Map<String, Object> dataMap, Map<String, Object> paraMap)
            throws Exception {
//        String milepostid = ConvertUtil.convertToString(paraMap.get("milepostcode"));
//        StringBufferProxy sql = new StringBufferProxy();
//        sql.appendSingle("operatecode='{0}' and enabled=1", milepostid);
//        List<SdProjectMilepostEntity> sdProjectMilepostEntityList = this.sdProjectMilepostService
//                .queryByWhere(sql.toString());
//        if(sdProjectMilepostEntityList.size()==0) {
//            sql.clear();
//            sql.appendSingle("operatecode='{0}'", milepostid);
//            sdProjectMilepostEntityList = sdProjectMilepostService
//                    .queryByWhere(sql.toString());
//        }
//        int sortcode = sdProjectMilepostEntityList.get(0).getSortcode();
//        sql.clear();
//        sql.appendSingle("milepostcode='{0}' and enabled = 1 order by taskcode desc", milepostid);
//        List<SdProjectTaskEntity> sdProjectTaskEntities = this.service
//                .queryByWhere(sql.toString());
//        if (sdProjectTaskEntities.size() > 0) {
//            String[] split = sdProjectTaskEntities.get(0).getTaskcode().split("-");
//            int value = Integer.parseInt(split[1]);
//            ++value;
//            split[1] = value + "";
//            String code1 = split[0] + "-" + split[1];
//            paraMap.put("taskcode", code1);
//        } else {
//            String code2 = sortcode + "-1";
//            paraMap.put("taskcode", code2);
//        }
    }


    @Override
    protected void beforeUpdate(Map<String, Object> dataMap, Map<String, Object> paraMap) throws Exception {
        super.beforeUpdate(dataMap, paraMap);
        String taskid = ConvertUtil.convertToString(paraMap.get("id"));
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle("taskid = '{0}' and state = '0'", taskid);
        List<GpmProjectTaskFeedbackEntity> sdProjectTaskFeedbackEntities = gpmProjectTaskFeedbackService.queryByWhere(sql.toString());
        for(GpmProjectTaskFeedbackEntity gpmProjectTaskFeedbackEntity : sdProjectTaskFeedbackEntities) {
        	gpmProjectTaskFeedbackEntity.setPlanenddate(ConvertUtil.convertToDate(paraMap.get("planenddate")));
        	gpmProjectTaskFeedbackEntity.setTaskname(ConvertUtil.convertToString(paraMap.get("taskname")));
        	gpmProjectTaskFeedbackService.updateEntity(gpmProjectTaskFeedbackEntity);
        }
        
    }

    /**
     * @Title:
     * @description: 更新进行中的任务责任人
     * @param paraMap
     * @return
     * @author:
     * @date:
     * @modify:
     */
    @PutMapping(value = "/updateResponsible")
    public ResponseResult<Object> updateResponsible(@RequestBody(required = false) Map<String, Object> paraMap) {
        try {
            paraMap = BaseUtil.decodeSecureMap(paraMap);
            GpmProjectTaskEntity gpmProjectTaskEntity = this.service.queryById(ConvertUtil.convertToString(paraMap.get("id")));
            gpmProjectTaskEntity.setResponsible(ConvertUtil.convertToString(paraMap.get("responsible")));
            gpmProjectTaskEntity.setResponsiblecode(ConvertUtil.convertToString(paraMap.get("responsiblecode")));
            this.service.updateEntity(gpmProjectTaskEntity);
            return ResponseResult.ok("修改成功");
        } catch (Exception ex) {
            return handleControllerException(ex);
        }
    }
    /**
     * @Title:
     * @description:获取该任务的进度更新
     * @param paraMap
     * @return
     * @author: houyuhang
     * @date: 2021年11月3日
     * @modify:
     */
    @GetMapping(value = "/queryTaskFeedbackList")
    public ResponseResult<Object> queryTaskFeedbackList(
            @RequestParam(required = false) Map<String, Object> paraMap) {
        String taskid = ConvertUtil.convertToString(paraMap.get("taskid"));
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle("taskid = '{0}' and state < 9", taskid);
        List<GpmProjectTaskFeedbackEntity> gpmProjectTaskFeedbackEntityList = gpmProjectTaskFeedbackService.queryByWhere(sql.toString());
        return ResponseResult.ok(gpmProjectTaskFeedbackEntityList);
    }
    /**
     * @Title:
     * @description:获取该任务的任务关闭信息
     * @param paraMap
     * @return
     * @author: houyuhang
     * @date: 2021年12月04日
     * @modify:
     */
    @GetMapping(value = "/queryTaskCloseList")
    public ResponseResult<Object> queryTaskCloseList(
            @RequestParam(required = false) Map<String, Object> paraMap) {
        String taskid = ConvertUtil.convertToString(paraMap.get("taskid"));
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle("taskid = '{0}' and state < 9", taskid);
        List<GpmProjectTaskCloseEntity> gpmProjectTaskCloseEntityList = gpmProjectTaskCloseService.queryByWhere(sql.toString());
        return ResponseResult.ok(gpmProjectTaskCloseEntityList);
    }
    
	/***
	 * @description: 查询来源产品信息
	 * @param paraMap
	 * @return
	 * @author: jiangtao1
	 * @date: 2022/1/11 9:50
	 * @modify:
	 */
	@GetMapping({"/queryTaskInfo"})
	public ResponseResult<Object> queryTaskInfo(@RequestParam(required = false) Map<String, Object> paraMap) {
		try {
			paraMap = BaseUtil.decodeSecureMap(paraMap);
			String code = ConvertUtil.convertToString(paraMap.get("code"));
			StringBufferProxy sql = new StringBufferProxy();
			sql.appendSingle("{0} = {1}", GpmProjectTaskEntity.FieldMilepostcode,code);
			List<Map<String, Object>> tempList = this.service.queryMapByWhere(sql.toString());
			Map<String,Object> result = new HashMap<String,Object>();
			result.put("dataList",tempList);
			return ResponseResult.ok(result);
		} catch (Exception var7) {
			return this.handleControllerException(var7);
		}
	}
	
	/***
	 * @description: 查询某个产品还有多少未发货
	 * @param paraMap
	 * @return
	 * @author: hudeyong
	 * @date: 2022/1/11 9:50
	 * @modify:
	 */
	@GetMapping(value = "/queryProductDeliveryNum")
	public ResponseResult<Object> queryProductDeliveryNum(@RequestParam(required = false) Map<String, Object> paraMap) {
		Map<String,Object> codeMap = new HashMap<String, Object>();
		String projectid = ConvertUtil.convertToString(paraMap.get("projectid"));
		String productname = ConvertUtil.convertToString(paraMap.get("productname"));
		int thisamount = ConvertUtil.convertToInt(paraMap.get("thisamount"));
		long id = ConvertUtil.convertToLong(paraMap.get("id"));
		StringBufferProxy sql = new StringBufferProxy();
		sql.appendSingle("PROJECTID =  '{0}' and PRODUCTNAME  like '{1}'", projectid,productname);
		List<GpmProjectTaskEntity> sdProjectTaskEntities = this.service.queryByWhere(sql.toString());
		int delivery = thisamount;
		sql.clear();
		sql.appendSingle("projectid = '{0}' and PRODUCTNAME  like '{1}'", projectid,productname);
		codeMap.put("delivery", delivery);
		return ResponseResult.ok(codeMap);
	}
	
	/***
	 * @description:任务变更时，同步修改当前任务反馈
	 * @param paraMap
	 * @return
	 * @author: hudeyong
	 * @date: 2022/1/11 9:50
	 * @modify:
	 */
	@GetMapping(value = "/changeTaskInfo")
	public ResponseResult<Object> changeTaskInfo(@RequestParam(required = false) Map<String, Object> paraMap) {
		Map<String,Object> codeMap = new HashMap<String, Object>();
		String projectid = ConvertUtil.convertToString(paraMap.get("projectid"));
		String productname = ConvertUtil.convertToString(paraMap.get("productname"));
		int thisamount = ConvertUtil.convertToInt(paraMap.get("thisamount"));
		long id = ConvertUtil.convertToLong(paraMap.get("id"));
		StringBufferProxy sql = new StringBufferProxy();
		sql.appendSingle("PROJECTID =  '{0}' and PRODUCTNAME  like '{1}'", projectid,productname);
		List<GpmProjectTaskEntity> sdProjectTaskEntities = this.service.queryByWhere(sql.toString());
		int delivery = thisamount;
		sql.clear();
		sql.appendSingle("SOURCEID = '{0}' and PRODUCTNAME  like '{1}'", projectid,productname);
		codeMap.put("delivery", delivery);
		return ResponseResult.ok("");
	}
}

